package com.weidong.poidemo.entity;

import com.weidong.poidemo.annotation.ExcelAttribute;
import jdk.nashorn.internal.ir.annotations.Reference;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

/**
 * @author weidong
 * @version 1.0
 * @date 2017/11/18 14:26
 * @description excel 实体
 */


@Entity
@Table(name = "excel")
@Getter
@Setter
@NoArgsConstructor
public class Excel implements Serializable {

    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)   //自增长
    @ExcelAttribute(sort = 0)
    private int id;
    @ExcelAttribute(sort = 1)
    private String name;
    @ExcelAttribute(sort = 2)
    private String age;
    @ExcelAttribute(sort = 3)
    private Date birthday;

    @Reference
    public Excel(Object [] values) throws ParseException {
        //年龄	姓名	生日
        this.age = values[1].toString();
        this.name = values[2].toString();
        this.birthday = (Date) values[3];
    }
}
